package com.imc.platform.base.leavenotes;

import com.imc.core.utils.MenuUtils;
import com.imc.platform.base.category.pojo.Category;
import com.imc.platform.base.notice.pojo.Notice;
import com.imc.platform.base.notice.pojo.NoticeAttach;
import com.imc.platform.base.notice.service.INoticeService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 类描述: 舞苑简介管理controller
 * 开发者:SJC
 * 创建时间:2018-8-17 16:37:33
 */
@Slf4j
@Controller
public class LeaveNotesController {

    @Autowired
    INoticeService iNoticeService;

    @Autowired
    MenuUtils menuUtils;


    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    public static class ReqTuple{
        List<String> memberList;
        String noticeId;
        String contentDetail;
        String title;
        String type;
        String authorId;
    }

    /**
     * 方法描述:详情查询 跳到编辑
     * SJC 2018-8-27 16:14:31
     */
    @GetMapping("/index/toUpdateLeaveNotesTiny")
    public String toUpdateLeaveNotesTiny(Model model,HttpServletRequest request){
        String ntId = "13";
        model.addAttribute("menu", menuUtils.getMenuByRoleId(request,"109"));
        Notice nt = iNoticeService.queryNoticeById(ntId);
        if(!"".equals(nt.getContent())){
            nt.setContent(nt.getContent());
        }
        nt.setSendIdList(iNoticeService.querySendMember(ntId,nt.getAuthorId()));
        model.addAttribute("notice", nt);
        List<NoticeAttach> naList = iNoticeService.queryNoticeAttachList(ntId);
        model.addAttribute("naList", naList);

        List<Category> categoryList = iNoticeService.queryCategory();
        model.addAttribute("categoryList",categoryList);

        model.addAttribute("type", "29");

        return "base/leavenotes/updateLeaveNotesTinymce";

    }
}